# k = open('C:\\Users\\CNCCD003\\Desktop\\python-project\\pdemo6.py','r',encoding = 'UTF-8')
# # print(type(k))
# # # print(k.read(10)) 
# # # print(k.readlines())
# # #多次调用read，第二个read会在第一个read结尾开始读取，readlines同  

# for lines in k:
#   print(lines,end='')

# k.close() 

# with open('C:\\Users\\CNCCD003\\Desktop\\python-project\\pdemo5.py','r',encoding = 'UTF-8') as k:
#   for lines in k:
#     print(lines,end='')

"""
打开读
count = 0
with open('C:/Users/CNCCD003/Desktop/python-project/demo2.py','r',encoding='utf-8') as k:
  for lines in k:
    lines = lines.strip()
    words = lines.split(' ')
    print(lines)
    for word in words:
      if word == 's':
        count += 1

print(f's出现的次数为:{count}')

k.close()
"""
"""
打开写 w 模式
"""
import time
count = 0
with open('C:/Users/CNCCD003/Desktop/kankannide.txt','w',encoding='utf-8') as k:
  k.write('hello world')
  # k.flush()
  # time.sleep( 60000)
  # for lines in k:
  #   lines = lines.strip()
  #   words = lines.split(' ')
  #   print(lines)
  #   for word in words:
  #     if word == 's':
  #       count += 1

# print(f's出现的次数为:{count}')

k.close()

# a模式
with open('C:/Users/CNCCD003/Desktop/kankannide.txt','a',encoding='UTF-8') as k:
  k.write('\n哥们在第二行')

  k.close()